/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ongmanager.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author wbettencourt
 */
@Entity
@Table(name = "ong_documento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OngDocumento.findAll", query = "SELECT o FROM OngDocumento o"),
    @NamedQuery(name = "OngDocumento.findByEstado", query = "SELECT o FROM OngDocumento o WHERE o.estado = :estado"),
    @NamedQuery(name = "OngDocumento.findByFecha", query = "SELECT o FROM OngDocumento o WHERE o.fecha = :fecha"),
    @NamedQuery(name = "OngDocumento.findByIdOng", query = "SELECT o FROM OngDocumento o WHERE o.ongDocumentoPK.idOng = :idOng"),
    @NamedQuery(name = "OngDocumento.findByIdDocumento", query = "SELECT o FROM OngDocumento o WHERE o.ongDocumentoPK.idDocumento = :idDocumento")})
public class OngDocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OngDocumentoPK ongDocumentoPK;
    @Basic(optional = false)
    @Column(name = "Estado")
    private String estado;
    @Basic(optional = false)
    @Column(name = "Fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @JoinColumn(name = "IdOng", referencedColumnName = "IdONG", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Ong ong;
    @JoinColumn(name = "IdDocumento", referencedColumnName = "IdDocumento", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Documento documento;

    public OngDocumento() {
    }

    public OngDocumento(OngDocumentoPK ongDocumentoPK) {
        this.ongDocumentoPK = ongDocumentoPK;
    }

    public OngDocumento(OngDocumentoPK ongDocumentoPK, String estado, Date fecha) {
        this.ongDocumentoPK = ongDocumentoPK;
        this.estado = estado;
        this.fecha = fecha;
    }

    public OngDocumento(int idOng, int idDocumento) {
        this.ongDocumentoPK = new OngDocumentoPK(idOng, idDocumento);
    }

    public OngDocumentoPK getOngDocumentoPK() {
        return ongDocumentoPK;
    }

    public void setOngDocumentoPK(OngDocumentoPK ongDocumentoPK) {
        this.ongDocumentoPK = ongDocumentoPK;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Ong getOng() {
        return ong;
    }

    public void setOng(Ong ong) {
        this.ong = ong;
    }

    public Documento getDocumento() {
        return documento;
    }

    public void setDocumento(Documento documento) {
        this.documento = documento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ongDocumentoPK != null ? ongDocumentoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OngDocumento)) {
            return false;
        }
        OngDocumento other = (OngDocumento) object;
        if ((this.ongDocumentoPK == null && other.ongDocumentoPK != null) || (this.ongDocumentoPK != null && !this.ongDocumentoPK.equals(other.ongDocumentoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ongmanager.model.OngDocumento[ ongDocumentoPK=" + ongDocumentoPK + " ]";
    }
    
}
